<?php

namespace App\Admin\Controllers\Dog;

use App\Models\Dog\DogOwner;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;

class DoguserController extends AdminController
{
    /**
     * Title for current resource.
     *
     * @var string
     */
    protected $title = '宠物用户';

    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        $grid = new Grid(new DogOwner());

        $grid->column('id', __('field.id'));
        $grid->column('name', __('field.name'));
        $grid->column('phone', __('field.phone'));
//        $grid->column('password', __('field.password'));
        $grid->column('dog_type', __('field.dog_type'));
        $grid->column('city', __('field.city'));
        $grid->column('area', __('field.area'));
        $grid->column('detail_address', __('field.detail_address'));
        $grid->column('created_at', __('field.created_at'));
//        $grid->column('updated_at', __('field.updated_at'));
//        $grid->column('deleted_at', __('field.deleted_at'));

        return $grid;
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     * @return Show
     */
    protected function detail($id)
    {
        $show = new Show(DogOwner::findOrFail($id));

        $show->field('id', __('field.id'));
        $show->field('name', __('field.name'));
        $show->field('phone', __('field.phone'));
        $show->field('password', __('field.password'));
        $show->field('dog_type', __('field.dog_type'));
        $show->field('city', __('field.city'));
        $show->field('area', __('field.area'));
        $show->field('detail_address', __('field.detail_address'));
        $show->field('created_at', __('field.created_at'));
        $show->field('updated_at', __('field.updated_at'));
        $show->field('deleted_at', __('field.deleted_at'));

        return $show;
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        $form = new Form(new DogOwner());

        $form->text('name', __('field.name'));
        $form->mobile('phone', __('field.phone'));
        $form->password('password', __('field.password'));
        $form->text('dog_type', __('field.dog_type'));
        $form->text('city', __('field.city'));
        $form->text('area', __('field.area'));
        $form->text('detail_address', __('field.detail_address'));

        return $form;
    }
}
